<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>$children</title>
  <script src="../../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <parent/>
  </div>

  <script>
    let childOne = {
      template: `<div>children1</div>`,
      methods: {
        handle() {
          console.log('childOne title')
        }
      }
    }

    let childTwo = {
      template: `<div>children2</div>`,
      methods: {
        handle() {
          console.log('childTwo title')
        }
      }
    }
    
    Vue.component("parent", {
      template:`
        <div>
          <child-one/>
          <child-two/>
          <button @click="getChildren">获取子组件</button>
        </div>`,
      components: { childOne, childTwo },
      methods: {
        getChildren() {
          console.log(this.$children)
          this.$children[0].handle()
          this.$children[1].handle()
        }
      }
    })

    let vm = new Vue({
      el: '#app'
    })
    console.log(vm)
  </script>
</body>

</html>